<?php

class TestMoneyController extends FrontBaseC {

    public function actions() {
        
    }

    public function actionIndex() {
        $this->layout = 'theme.views.layouts.FrontNoHeaderContent';

        $connection = Yii::app()->db;
        $sql = "SELECT m.uid as uid,username,email,money FROM tk_members m LEFT JOIN tk_members_money mm ON m.uid = mm.uid where mm.money>0";


        $command = $connection->createCommand($sql);
        $dataReader = $command->query();
        $rows = $dataReader->readAll();
        $members = array();
        $i = 0;
        $MembersInfoTaobaoModel = new MembersInfoTaobaoModel();
        $MembersTaobaoModel = new MembersTaobaoModel();


        foreach ($rows as $row) {
            $members[$i] = $row;

            $Mitm = $MembersInfoTaobaoModel->model()->find("uid = :uid", array(":uid" => $row['uid']));

            $members[$i]['register_ww'] = "";
            if ($Mitm) {
                $members[$i]['register_ww'] = $Mitm->taobao_user_nick . "/";
            }

            $Mtm = $MembersTaobaoModel->model()->find("uid = :uid", array(":uid" => $row['uid']));

            $members[$i]['ww'] = "";
            if ($Mtm) {
                $members[$i]['ww'] = $Mtm->taobao_user_nick;
            }
            $i++;
        }

        $this->render('index', array(
            'members' => $members,
        ));
    }

}
